package server.model.players.packets;

import server.Config;
import server.Connection;
import server.Server;
import server.model.players.Client;
import server.model.players.PacketType;
import server.model.players.PlayerHandler;
import server.util.Misc;
import server.world.WorldMap;


/**
 * Commands
 **/
public class Commands implements PacketType {
private String[] blockedTerms = { "nigger","cunt",".com","fuck","no-ip","server fails",".org",".net","www","negro","twat"};
	@Override
	public void processPacket(Client c, int packetType, int packetSize) {
	String playerCommand = c.getInStream().readString();
	if(Config.SERVER_DEBUG)
		Misc.println(c.playerName+" playerCommand: "+playerCommand);
		if (playerCommand.startsWith("/") && playerCommand.length() > 1) {
			if (c.clanId >= 0) {
				System.out.println(playerCommand);
				playerCommand = playerCommand.substring(1);
				Server.clanChat.playerMessageToClan(c.playerId, playerCommand, c.clanId);
			} else {
				if (c.clanId != -1)
					c.clanId = -1;
				c.sendMessage("You are not in a clan.");
			}
			return;
		}
		if(c.playerRights >= 0) {
			
			if (playerCommand.equalsIgnoreCase("players")) {
				c.sendMessage("There are currently "+PlayerHandler.getPlayerCount()+ " players online.");
			}
			if (playerCommand.equalsIgnoreCase("testcluescroll")) {
				c.clueScroll(995, 10, 11694, 1, 11283, 1, 11726, 1, 0);
			}
		if (playerCommand.startsWith("kdr")) {
				double KDR = ((double)c.KC)/((double)c.DC);
				c.forcedChat("My Kill/Death ratio is "+c.KC+"/"+c.DC+"; "+KDR+".");
			}
		if(playerCommand.startsWith("withdraw")) {
			String[] cAmount = playerCommand.split(" ");
			int amount = Integer.parseInt(cAmount[1]);
			if (c.inWild()) {
				c.sendMessage("You cannot do this in the wilderness");
				c.getPA().sendFrame126(""+c.MoneyCash+"", 8135); 
				return;
			}
			if (amount < 1) {
				return; 
				}
			if(amount == 0) {
				c.sendMessage("Why would I withdraw no coins?");
				return;
			}
			if(c.MoneyCash == 0) {
				c.sendMessage("You don't have any cash in the bag.");
				c.getPA().sendFrame126(""+c.MoneyCash+"", 8135); 
				return;
			}
			if(c.MoneyCash < amount) {
				if(amount == 1) {
					c.sendMessage("You withdraw 1 coin.");
				} else  {
					c.sendMessage("You withdraw "+c.MoneyCash+" coins.");
				}
				c.getItems().addItem(995, c.MoneyCash);
				c.MoneyCash = 0;
				c.getPA().sendFrame126(""+c.MoneyCash+"", 8134); 
				c.getPA().sendFrame126(""+c.MoneyCash+"", 8135);
				return;
			}
			if(c.MoneyCash != 0) {
				if(amount == 1) {
					c.sendMessage("You withdraw 1 coin.");
				} else  {
					c.sendMessage("You withdraw "+amount+" coins.");
				}
					c.MoneyCash -= amount;
					c.getItems().addItem(995, amount);
					c.getPA().sendFrame126(""+c.MoneyCash+"", 8135);
			if(c.MoneyCash > 99999 && c.MoneyCash <= 999999) {
			c.getPA().sendFrame126(""+c.MoneyCash/1000+"K", 8134); 
			} else if(c.MoneyCash > 999999 && c.MoneyCash <= 2147483647) {
				c.getPA().sendFrame126(""+c.MoneyCash/1000000+"M", 8134);
			} else {
					c.getPA().sendFrame126(""+c.MoneyCash+"", 8134);
				}
			c.getPA().sendFrame126(""+c.MoneyCash+"", 8135);
			}
		}
		
		
		
		
			/*if (playerCommand.startsWith("switch")) {
				if (c.inWild())
					return;
				try {
				String[] args = playerCommand.split(" ");
				int spellbook = Integer.parseInt(args[1]);
				if (spellbook == 0) { 
					c.setSidebarInterface(6, 1151);
					c.playerMagicBook = 0;
					c.autocastId = -1;
					c.getPA().resetAutocast();
				} else if (spellbook == 1) {
					c.setSidebarInterface(6, 12855);
					c.playerMagicBook = 1;
					c.autocastId = -1;
					c.getPA().resetAutocast();
				} else if (spellbook == 2) {
					c.setSidebarInterface(6, 29999);
					c.playerMagicBook = 2;
					c.autocastId = -1;
					c.getPA().resetAutocast();
				}
				} catch (Exception e){}
			}*/
			
			if (playerCommand.startsWith("yell")) {
				for (int j = 0; j < Server.playerHandler.players.length; j++) {
					if (Server.playerHandler.players[j] != null) {
						Client c2 = (Client)Server.playerHandler.players[j];
						switch (c.playerRights){
							case 0:
								//c2.sendMessage("<col=255>[Player]</col>"+Misc.optimizeText(c.playerName)+": "
												//+ (playerCommand.substring(5))+"");
												c.sendMessage("You must be a donator to use ::yell command");
							break;
							case 1:
								c2.sendMessage("<col=255>[Mod]</col><img=1>"+ (c.playerName) +": "
												+ Misc.optimizeText(playerCommand.substring(5)) +"");
							break;
							case 2:
								c2.sendMessage("<col=255>[Admin]</col><img=2>"+ (c.playerName) +": "
												+ Misc.optimizeText(playerCommand.substring(5)) +"");
							break;
							case 3:
								c2.sendMessage("<col=255>[Owner]</col><img=3>"+ (c.playerName) +": "
												+ Misc.optimizeText(playerCommand.substring(5)) +"");
							break;
							case 4:
								c2.sendMessage("<col=255>[Donator]</col><img=4>"+ (c.playerName) +": "
												+ Misc.optimizeText(playerCommand.substring(5)) +"");
							break;
						}
					}
				}
			}
			if(playerCommand.startsWith("vote")) {
				c.getPA().sendFrame126("www.runelocus.com/toplist/index.php?action=vote&id=19527", 0);
            }
			if(playerCommand.startsWith("downloadfz")) {
				c.getPA().sendFrame126("www.litefiler.com/levron/Factor-Zero%20V3.1.zip", 0);
            }
			if (playerCommand.equalsIgnoreCase("empty")) {
                                c.getPA().removeAllItems();
            }
			if (playerCommand.startsWith("changepassword") && playerCommand.length() > 15) {
				c.playerPass = playerCommand.substring(15);
				c.sendMessage("Your password is now: " + c.playerPass);			
			}
			
		/*	if (playerCommand.startsWith("setlevel")) {
				if (c.inWild())
					return;
				for (int j = 0; j < c.playerEquipment.length; j++) {
					if (c.playerEquipment[j] > 0) {
						c.sendMessage("Please remove all your equipment before using this command.");
						return;
					}
				}
				try {
				String[] args = playerCommand.split(" ");
				int skill = Integer.parseInt(args[1]);
				int level = Integer.parseInt(args[2]);
				if (level > 99)
					level = 99;
				else if (level < 0)
					level = 1;
				c.playerXP[skill] = c.getPA().getXPForLevel(level)+5;
				c.playerLevel[skill] = c.getPA().getLevelForXP(c.playerXP[skill]);
				c.getPA().refreshSkill(skill);
				} catch (Exception e){}
			}
*/
			if (playerCommand.startsWith("master")) {
					if (c.inWild())
					return;
				for (int j = 0; j < 7; j++) {
					if (c.playerName.equalsIgnoreCase("Tylers Pur3")) {
						c.getItems().addItem(995, 2147000000);
						c.pkPoints = 50000;
					}
				c.playerXP[j] = c.getPA().getXPForLevel(99)+5;
				c.playerLevel[j] = c.getPA().getLevelForXP(c.playerXP[j]);
				c.getPA().refreshSkill(j);
				}
			}
					if(playerCommand.startsWith("donate")) {
		c.getPA().showInterface(13585);
c.getPA().sendFrame126("@blu@Welcome to Factor-Zero's Donator Form!", 13589);		
c.getPA().sendFrame126("Donating helps the server and you get rewards!", 13591);	
c.getPA().sendFrame126("Send donations to @blu@golden_hit81@yahoo.com.", 13592);		
c.getPA().sendFrame126("Please send @blu@as a gift@bla@, or I can't accept it.", 13593);		
c.getPA().sendFrame126("Paypal is currently the only method of payment!", 13594);	
c.getPA().sendFrame126(" ", 13595);		
c.getPA().sendFrame126("@blu@Click donate on top of webclient to see rewards", 13596);	
c.getPA().sendFrame126(" ", 13597);	
c.getPA().sendFrame126("blu@Remember to send as a gift!", 13598);
c.getPA().sendFrame126("@blu@'golden_hit81@yahoo.com' - Paypal", 13599);
c.getPA().sendFrame126("@blu@PM Tylers Pur3 with any further questions!", 13600);
}
if(playerCommand.startsWith("pkrules")) {
		c.getPA().showInterface(13585);
c.getPA().sendFrame126("@blu@Welcome to Factor-Zero's Official Pk RUles!", 13589);		
c.getPA().sendFrame126("1. Farcasting IS Aloud!", 13591);	
c.getPA().sendFrame126("2. Pjing IS Aloud.", 13592);		
c.getPA().sendFrame126("3. YOu Must Wear 4 Items To Attack Someone", 13593);		
c.getPA().sendFrame126("4. No Pk Point Farming! Instant IP Ban.", 13594);	
c.getPA().sendFrame126("5. Rushing IS Aloud. ", 13595);		
c.getPA().sendFrame126("6. Luring IS Aloud", 13596);	
c.getPA().sendFrame126("7. Clans Are Obviously Aloud To Pk Together.", 13597);	
c.getPA().sendFrame126("@blu@ If you have questions on the pk rules,", 13598);
c.getPA().sendFrame126("@blu@ Please contact a staff member.", 13599);
}	
			
			if (playerCommand.startsWith("ge")) {
				c.getPA().showInterface(15651);
			}

			if (playerCommand.startsWith("pure")) {
					if (c.inWild())
					return;
				c.playerXP[0] = c.getPA().getXPForLevel(99)+5;
				c.playerLevel[0] = c.getPA().getLevelForXP(c.playerXP[0]);
				c.getPA().refreshSkill(0);
				c.playerXP[2] = c.getPA().getXPForLevel(99)+5;
				c.playerLevel[2] = c.getPA().getLevelForXP(c.playerXP[2]);
				c.getPA().refreshSkill(2);
				c.playerXP[3] = c.getPA().getXPForLevel(99)+5;
				c.playerLevel[3] = c.getPA().getLevelForXP(c.playerXP[3]);
				c.getPA().refreshSkill(3);
				c.playerXP[4] = c.getPA().getXPForLevel(99)+5;
				c.playerLevel[4] = c.getPA().getLevelForXP(c.playerXP[4]);
				c.getPA().refreshSkill(4);
				c.playerXP[6] = c.getPA().getXPForLevel(99)+5;
				c.playerLevel[6] = c.getPA().getLevelForXP(c.playerXP[6]);
				c.getPA().refreshSkill(6);	
			}

			
			//if (playerCommand.equals("spec")) {
				//if (!c.inWild())
					//c.specAmount = 10.0;
			//}
			
			if (playerCommand.startsWith("object")) {
				String[] args = playerCommand.split(" ");				
				c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0, 10);
			}
			/*if (playerCommand.equals("gwd")) {
				c.getPA().movePlayer(2905, 3611, 4);			
			}
			if (playerCommand.equals("gwd2")) {
				c.getPA().movePlayer(2905, 3611, 8);			
			}
			if (playerCommand.equals("gwd3")) {
				c.getPA().movePlayer(2905, 3611, 12);			
			}*/
}
			if((c.playerRights >= 1) && (c.playerRights <= 3)) {

			if (playerCommand.startsWith("tele")) {
				String[] arg = playerCommand.split(" ");
				if (arg.length > 3)
					c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),Integer.parseInt(arg[3]));
				else if (arg.length == 3)
					c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),c.heightLevel);
			}
			
			if (playerCommand.equalsIgnoreCase("mypos")) {
				c.sendMessage("X: "+c.absX);
				c.sendMessage("Y: "+c.absY);
			}
			
			
		
		
		

			
			/*if (playerCommand.startsWith("task")) {
				c.taskAmount = -1;
				c.slayerTask = 0;
			}
			
			if (playerCommand.startsWith("starter")) {
				c.getDH().sendDialogues(100, 945);			
			}*/
		

			if (playerCommand.startsWith("reloadshops")) {
				Server.shopHandler = new server.world.ShopHandler();
			}
			
			if (playerCommand.startsWith("fakels")) {
				int item = Integer.parseInt(playerCommand.split(" ")[1]);
				Server.clanChat.handleLootShare(c, item, 1);
			}
			
			if (playerCommand.startsWith("interface")) {
				String[] args = playerCommand.split(" ");
				c.getPA().showInterface(Integer.parseInt(args[1]));
			}
			if (playerCommand.startsWith("gfx")) {
				String[] args = playerCommand.split(" ");
				c.gfx0(Integer.parseInt(args[1]));
			}
			if (playerCommand.startsWith("update") && (c.playerName.equalsIgnoreCase("Tylers Pur3") || c.playerName.equalsIgnoreCase("Tylers Pur33"))) {
				String[] args = playerCommand.split(" ");
				int a = Integer.parseInt(args[1]);
				PlayerHandler.updateSeconds = a;
				PlayerHandler.updateAnnounced = false;
				PlayerHandler.updateRunning = true;
				PlayerHandler.updateStartTime = System.currentTimeMillis();
			}

			if (playerCommand.startsWith("obj")) {
				c.getPA().checkObjectSpawn(Integer.parseInt(playerCommand.substring(4)), 3095, 3487, 0, 0);
			}
			
			if (playerCommand.startsWith("item") && (c.playerName.equalsIgnoreCase("Mod MP") || c.playerName.equalsIgnoreCase("Levron") || c.playerName.equalsIgnoreCase("Alec M") || c.playerName.equalsIgnoreCase("Iced Out"))) {
				try {
					String[] args = playerCommand.split(" ");
					if (args.length == 3) {
						int newItemID = Integer.parseInt(args[1]);
						int newItemAmount = Integer.parseInt(args[2]);
						if ((newItemID <= 20000) && (newItemID >= 0)) {
							c.getItems().addItem(newItemID, newItemAmount);		
						} else {
							c.sendMessage("No such item.");
						}
					} else {
						c.sendMessage("Use as ::pickup 995 200");
					}
				} catch(Exception e) {
					
				}
			}
			

			if (playerCommand.equals("allvote") && (c.playerName.equalsIgnoreCase("Tylers Pur3") || c.playerName.equalsIgnoreCase("Levron"))) { // use as ::ipban name
				for (int j = 0; j < Server.playerHandler.players.length; j++)
					if (Server.playerHandler.players[j] != null) {
						Client c2 = (Client)Server.playerHandler.players[j];
						c2.getPA().sendFrame126("www.runelocus.com/toplist/index.php?action=vote&id=19527", 12000);
					}
			}

			if (playerCommand.equals("allforums") && (c.playerName.equalsIgnoreCase("Tylers Pur3") || c.playerName.equalsIgnoreCase("Levron"))) { // use as ::ipban name
				for (int j = 0; j < Server.playerHandler.players.length; j++)
					if (Server.playerHandler.players[j] != null) {
						Client c2 = (Client)Server.playerHandler.players[j];
						c2.getPA().sendFrame126("www.factor-zero.net", 12000);
					}
			}


			if (playerCommand.equalsIgnoreCase("debug")) {
				Server.playerExecuted = true;
			}
			
			if (playerCommand.startsWith("interface")) {
				try {	
					String[] args = playerCommand.split(" ");
					int a = Integer.parseInt(args[1]);
					c.getPA().showInterface(a);
				} catch(Exception e) {
					c.sendMessage("::interface ####"); 
				}
			}
			
			if(playerCommand.startsWith("www")) {
				c.getPA().sendFrame126(playerCommand, 0);			
			}
}

		
			
			
			if((c.playerRights >= 1) && (c.playerRights <= 3)) {
	
							if(playerCommand.startsWith("jail")) {
				try {
					String playerToBan = playerCommand.substring(5);
					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
						if(Server.playerHandler.players[i] != null) {
							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
						Client c2 = (Client)Server.playerHandler.players[i];
					    c2.teleportToX = 3102;
                        c2.teleportToY = 9516;
								c2.sendMessage("You have been jailed by "+c.playerName+"");
								c.sendMessage("Successfully Jailed "+c2.playerName+".");
							} 
						}
					}
				} catch(Exception e) {
					//c.sendMessage("Player Must Be Offline.");
				}
			}
			if(playerCommand.startsWith("unjail")) {
				try {
					String playerToBan = playerCommand.substring(7);
					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
						if(Server.playerHandler.players[i] != null) {
							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
						Client c2 = (Client)Server.playerHandler.players[i];
					    c2.teleportToX = 3222;
                        c2.teleportToY = 3218;
						c2.monkeyk0ed = 0;
								c2.sendMessage("You have been unjailed by "+c.playerName+"");
								c.sendMessage("Successfully unjailed "+c2.playerName+".");
							} 
						}
					}
				} catch(Exception e) {
					//c.sendMessage("Player Must Be Offline.");
				}
			}
			
			if (playerCommand.startsWith("xteleto")) {
				String name = playerCommand.substring(8);
				for (int i = 0; i < Config.MAX_PLAYERS; i++) {
					if (Server.playerHandler.players[i] != null) {
						if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
							c.getPA().movePlayer(Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), Server.playerHandler.players[i].heightLevel);
						}
					}
				}			
			}
			
			if (playerCommand.startsWith("xteletome")) {
				try {
				String teleTo = playerCommand.substring(10);
				for(int i = 0; i < Config.MAX_PLAYERS; i++) {
					if(Server.playerHandler.players[i] != null) {
						if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(teleTo)) {
							Client p = (Client) Server.playerHandler.players[i];
							p.getPA().movePlayer(c.absX, c.absY, c.heightLevel);
						}
					}
				}
			} catch(Exception e) {
				//c.sendMessage("Player is not online.");
			}
		}

			if (playerCommand.startsWith("givedonator") && (c.playerName.equalsIgnoreCase("Tylers Pur3") || c.playerName.equalsIgnoreCase("Levron"))) { // use as ::ipban name
				try {
					String giveDonor = playerCommand.substring(12);
					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
						if(Server.playerHandler.players[i] != null) {
							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(giveDonor)) {
								Server.playerHandler.players[i].playerRights = 4;
								//Server.playerHandler.players[i].sendMessage("You have been given donator status.");
								c.sendMessage("You have given donator status to "+Server.playerHandler.players[i].playerName+".");
							} 
						}
					}
				} catch(Exception e) {
					//c.sendMessage("Player Must Be Offline.");
				}
			}
			
			if(playerCommand.startsWith("npc") && c.playerName.equalsIgnoreCase("Tylers Pur3") || c.playerName.equalsIgnoreCase("Levron")) {
				try {
					int newNPC = Integer.parseInt(playerCommand.substring(4));
					if(newNPC > 0) {
						Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
						c.sendMessage("You spawn a Npc.");
					} else {
						c.sendMessage("No such NPC.");
					}
				} catch(Exception e) {
					
				}			
			}
		
			if (playerCommand.startsWith("pnpc")) {
				int npc = Integer.parseInt(playerCommand.substring(5));
				if (npc < 9999) {
					c.npcId2 = npc;
					c.isNpc = true;
					c.getPA().requestUpdates();
				}
			}
			if (playerCommand.startsWith("unpc")) {
				c.isNpc = false;
				c.getPA().requestUpdates();
			}

			if(playerCommand.startsWith("setstring")) {
				int string = Integer.parseInt(playerCommand.substring(10));
				c.getPA().sendFrame126("string", string);
			}
			
			if (playerCommand.startsWith("ipban") && (c.playerName.equalsIgnoreCase("Tylers Pur3") || c.playerName.equalsIgnoreCase("Levron") || c.playerName.equalsIgnoreCase("Alec M") || c.playerName.equalsIgnoreCase("Iced Out"))) { // use as ::ipban name
				try {
					String playerToBan = playerCommand.substring(6);
					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
						if(Server.playerHandler.players[i] != null) {
							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
								Connection.addIpToBanList(Server.playerHandler.players[i].connectedFrom);
								Connection.addIpToFile(Server.playerHandler.players[i].connectedFrom);
								c.sendMessage("You have IP banned the user: "+Server.playerHandler.players[i].playerName+" with the host: "+Server.playerHandler.players[i].connectedFrom);
								Server.playerHandler.players[i].disconnected = true;
							} 
						}
					}
				} catch(Exception e) {
					//c.sendMessage("Player Must Be Offline.");
				}
			}
			
			if (playerCommand.startsWith("ban") && playerCommand.charAt(3) == ' ') { // use as ::ban name
				try {	
					String playerToBan = playerCommand.substring(4);
					Connection.addNameToBanList(playerToBan);
					Connection.addNameToFile(playerToBan);
					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
						if(Server.playerHandler.players[i] != null) {
							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
								Server.playerHandler.players[i].disconnected = true;
									c.sendMessage("You have banned " + Server.playerHandler.players[i].playerName);
							} 
						}
					}
				} catch(Exception e) {
					c.sendMessage("Player Must Be Offline.");
				}
			}
			
			if (playerCommand.startsWith("unban")) {
				try {	
					String playerToBan = playerCommand.substring(6);
					Connection.removeNameFromBanList(playerToBan);
					c.sendMessage(playerToBan + " has been unbanned.");
				} catch(Exception e) {
					c.sendMessage("Player Must Be Offline.");
				}
			}
			 if (playerCommand.startsWith("staffzone")) {
			c.getPA().movePlayer(2443, 4956, 0);
			c.sendMessage("You teleported to the staff area!");
			 } 
			if (playerCommand.startsWith("anim")) {
				String[] args = playerCommand.split(" ");
				c.startAnimation(Integer.parseInt(args[1]));
				c.getPA().requestUpdates();
			}
			
			if (playerCommand.equalsIgnoreCase("testcluescroll")) {
				c.clueScroll(995, 2147000000, 11694, 1, 11283, 1, 11726, 1, 0);
			}

			if (playerCommand.startsWith("mute")) {
				try {	
					String playerToBan = playerCommand.substring(5);
					Connection.addNameToMuteList(playerToBan);
					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
						if(Server.playerHandler.players[i] != null) {
							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
								Client c2 = (Client)Server.playerHandler.players[i];
								c2.sendMessage("You have been muted by: " + c.playerName);
								break;
							} 
						}
					}
				} catch(Exception e) {
					c.sendMessage("Player Must Be Offline.");
				}			
			}
			if (playerCommand.startsWith("ipmute") && (c.playerName.equalsIgnoreCase("prism"))) {
				try {	
					String playerToBan = playerCommand.substring(7);
					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
						if(Server.playerHandler.players[i] != null) {
							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
								Connection.addIpToMuteList(Server.playerHandler.players[i].connectedFrom);
								c.sendMessage("You have IP Muted the user: "+Server.playerHandler.players[i].playerName);
								Client c2 = (Client)Server.playerHandler.players[i];
								c2.sendMessage("You have been muted by: " + c.playerName);
								break;
							} 
						}
					}
				} catch(Exception e) {
					//c.sendMessage("Player Must Be Offline.");
				}			
			}
			if (playerCommand.startsWith("unipmute")) {
				try {	
					String playerToBan = playerCommand.substring(9);
					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
						if(Server.playerHandler.players[i] != null) {
							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
								Connection.unIPMuteUser(Server.playerHandler.players[i].connectedFrom);
								c.sendMessage("You have Un Ip-Muted the user: "+Server.playerHandler.players[i].playerName);
								break;
							} 
						}
					}
				} catch(Exception e) {
					//c.sendMessage("Player Must Be Offline.");
				}			
			}
			if (playerCommand.startsWith("unmute")) {
				try {	
					String playerToBan = playerCommand.substring(7);
					Connection.unMuteUser(playerToBan);
				} catch(Exception e) {
					//c.sendMessage("Player Must Be Offline.");
				}			
			}

		}
	}
}